# Contributor: Andreas Laghamn <andreas.laghamn@gmail.com>
# Maintainer: Anjandev Momi <anjan@momi.ca>
pkgname=cppzmq
pkgver=4.10.0
pkgrel=0
pkgdesc="High-level C++ binding for ZeroMQ"
options="!check" # CMake fails to find catch_discover_tests
url="https://github.com/zeromq/cppzmq"
arch="noarch"
license="MIT"
makedepends="cmake zeromq-dev catch2 samurai"
source="$pkgname-$pkgver.tar.gz::https://github.com/zeromq/cppzmq/archive/v$pkgver.tar.gz
	"

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCPPZMQ_BUILD_TESTS=OFF \
		$CMAKE_CROSSOPTS .
	cmake --build build
}

check() {
	cd build
	CTEST_OUTPUT_ON_FAILURE=TRUE ctest
}

package() {
	DESTDIR="$pkgdir" cmake --install build

	mkdir -p "$pkgdir"/usr/lib
	mv "$pkgdir"/usr/share/cmake "$pkgdir"/usr/lib
}

sha512sums="
4a4f3c2a270b9b21591b08a81f2ab6a72693af213c115f2c0aa5b737fd0363d09dba92437f48268ff982e6c27d6830f79244599bd9198e3402c6cca566cea27a  cppzmq-4.10.0.tar.gz
"
